home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3995 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: ix.netcom.com!netnews
  2. From: miker3@ix.netcom.com (Mike Rubenstein)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Basic Question on SWITCH
  5. Date: Thu, 01 Feb 1996 03:48:41 GMT
  6. Organization: Netcom
  7. Message-ID: <31103648.28902464@nntp.ix.netcom.com>
  8. References: <4e4cu4$95f@vixen.cso.uiuc.edu> <4e8p6m$n8q@ns.RezoNet.NET> <TANMOY.96Jan26162346@qcd.lanl.gov> <4ehfuj$166g@ns.RezoNet.NET>
  9. NNTP-Posting-Host: ix-dc11-20.ix.netcom.com
  10. X-NETCOM-Date: Wed Jan 31  7:49:12 PM PST 1996
  11. X-Newsreader: Forte Agent .99c/16.141
  12.  
  13. ray@ultimate-tech.com (Ray Dunn) wrote:
  14.  
  15. > In referenced article, Tanmoy Bhattacharya says...
  16. > >
  17. > >In article <3108ED49.987@cmt.lpr.mail.carel.fi> Ari Lukumies
  18. > ><aril@cmt.lpr.mail.carel.fi> writes: 
  19. > ><snip>
  20. > >           if (strchr("0123456789", a))
  21. > >                   ... /* It was a digit, do something */
  22. > >
  23. > >A special case for digits:
  24. > >
  25. > >if ((unsigned)(a-'0')<10)
  26. > >   /* It _is_ a digit, do something */
  27. > >
  28. > >But then what is wrong with isdigit?
  29. > Indeed.  In the general case there is no guarantee that all the digits 
  30. > are consecutive as they are in ASCII, so the use of isdigit is the only 
  31. > portable way to go, although the strchr example works fine too, if 
  32. > slowly.
  33. > [As a matter of interest, MS 'C' uses a character table with bits 
  34. > defining all the various character types.  isdigit etc. uses this 
  35. > table. MS provides profiling functions which allows the customization 
  36. > of this table]
  37.  
  38. But one needn't worry about the general case.  This is comp.lang.c and
  39. in C the digits must be consecutive with '0' the smallest.  From ISO
  40. 5.2.1:
  41.  
  42.     In both the source and execution basic character sets, the 
  43.     value of each character after 0 in the above list of decimal 
  44.     digits shall be one grater than the value of the previous.
  45.  
  46.  
  47. Michael M Rubenstein
  48.